<div id="painel_interno">
    <div id="menu_topo">
        <div class="postmetadataheader">
            <h2 class="postheader">Gerenciador de eventos.</h2>
        </div>
        <div id="menu">
            <ul>
                <li><?= anchor('admin/eventos/insert', 'Adicionar', array('class' => 'ui-button botao')) ?></li>
                <li><?= anchor('admin/index', 'Fechar', array('class' => 'ui-button botao')) ?></li>
            </ul>
        </div>
    </div>
    <div id="modo">
    <?php
        switch (@$modo):
        default:
            ?>
            <div id="grid">
                <table border="0" width="100%" align="center" id="grid">
                    <thead>
                        <tr>
                            <th class="ui-widget-header">Cod</th>
                            <th class="ui-widget-header">Título</th>
                            <th class="ui-widget-header">Data inicial</th>
                            <th class="ui-widget-header">Valor normal</th>
                            <th class="ui-widget-header">Status</th>
                            <th class="ui-widget-header">Cadastro</th>
                            <th class="ui-widget-header" width="60"></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($lista as $row): ?>
                            <tr>
                                <td valign="middle"><?= $row->cod_evento; ?></td>
                                <td valign="middle"><?= $row->titulo; ?></td>
                                <td valign="middle"><?= mdate('%d/%m/%Y', strtotime($row->data_inicial)); ?></td>
                                <td valign="middle"><?= $row->valor_normal; ?></td>
                                <td valign="middle"><?= $row->status; ?></td>
                                <td valign="middle"><?= mdate('%d/%m/%Y', strtotime($row->data_cdastro)); ?></td>
                                <td valign="middle">
                                    <ul>
                                        <li class="ui-state-default ui-corner-all" title="Alterar">
                                            <?= anchor('admin/eventos/update/' . $row->cod_evento, 'Alterar', array('class' => 'ui-icon ui-icon-pencil')); ?>
                                        </li>
                                        <li class="ui-state-default ui-corner-all" title="Excluir">
                                            <?= anchor('admin/eventos/delete/' . $row->cod_evento, 'Apagar', array('class' => 'ui-icon ui-icon-trash', 'onclick' => 'return apagar()')); ?>
                                        </li>
                                    </ul>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
                <div id="resumo">
                    <span class="total">Total de <b><?= $total_registros; ?></b> registros.</span>
                    <span class="box_paginacao">
                        <?= $paginacao; ?>
                    </span>
                </div>
            </div>
            <?php
            break;
        case 'insert':
            ?>
            <form name="form_insert" action="<?= site_url('admin/eventos/save/'); ?>" method="POST" enctype="multipart/form-data" class="ui-widget-content">
                <table border="0" width="100%" align="center" class="ui-widget" id="table_form">
                    <thead>
                        <tr>
                            <th></th>
                            <th></th>
                        </tr>
                     </thead>
                     <tbody>
                         <tr>
                             <td width="150">Título</td>
                             <td><input type="text" name="titulo" value="<?= $row->titulo; ?>" size="55" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Data inicial</td>
                             <td><input type="text" name="data_inicial" value="<?= mdate('%d/%m/%Y', strtotime($row->data_inicial)); ?>" size="20" class="data" /></td>
                         </tr>
                         <tr>
                             <td>Data final</td>
                             <td><input type="text" name="data_final" value="<?= mdate('%d/%m/%Y', strtotime($row->data_final)); ?>" size="20" class="data" /></td>
                         </tr>
                         <tr>
                             <td colspan="2">
                                 <b>Detalhes</b><br/>
                                 <textarea name="detalhes" rows="9" cols="60" class="ckeditor"><?= $row->detalhes; ?></textarea>
                             </td>
                         </tr>
                         <tr>
                             <td>Foto</td>
                             <td><input type="file" name="userfile" size="35" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Local</td>
                             <td><input type="text" name="local" value="<?= $row->local; ?>" size="45" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Mapa</td>
                             <td><input type="text" name="mapa" value="<?= $row->mapa; ?>" size="45" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Site do evento</td>
                             <td><input type="text" name="site" value="<?= $row->site; ?>" size="45" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Telefone</td>
                             <td><input type="text" name="telefone" value="<?= $row->telefone; ?>" size="25" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Celular</td>
                             <td><input type="text" name="celular" value="<?= $row->celular; ?>" size="25" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Email</td>
                             <td><input type="text" name="email" value="<?= $row->email; ?>" size="45" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Valor normal</td>
                             <td><input type="text" name="valor_normal" value="<?= $row->valor_normal; ?>" size="15" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Valor antecipado</td>
                             <td><input type="text" name="valor_desconto" value="<?= $row->valor_desconto; ?>" size="15" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Validade do desconto</td>
                             <td><input type="text" name="data_desconto" value="<?= mdate('%d/%m/%Y', strtotime($row->data_desconto)); ?>" size="20" class="data" /></td>
                         </tr>
                         <tr>
                             <td>Status</td>
                             <td><input type="text" name="status" value="<?= $row->status; ?>" size="45" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Cadastro</td>
                             <td><input type="text" name="data_cdastro" value="<?= mdate('%d/%m/%Y', strtotime($row->data_cdastro)); ?>" size="20" class="data" /></td>
                         </tr>
                         <tr>
                             <td></td>
                             <td>
                                 <input type="submit" value="Salvar" name="bot_salvar" class="ui-button botao" />
                                 <?= anchor('admin/eventos', 'Cancelar'); ?>
                             </td>
                         </tr>
                     </tbody>
                 </table>
             </form>
             <?php
             break;
         case 'update':
             ?>
             <form name="form_update" action="<?= site_url('admin/eventos/save/' . $row->cod_evento); ?>" method="POST" enctype="multipart/form-data" class="ui-widget-content">
                 <table border="0" width="100%" align="center" class="ui-widget" id="table_form">
                     <thead>
                         <tr>
                             <th></th>
                             <th></th>
                         </tr>
                     </thead>
                     <tbody>
                         <tr>
                             <td width="150">Título</td>
                             <td><input type="text" name="titulo" value="<?= $row->titulo; ?>" size="55" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Data inicial</td>
                             <td><input type="text" name="data_inicial" value="<?= mdate('%d/%m/%Y', strtotime($row->data_inicial)); ?>" size="20" class="data" /></td>
                         </tr>
                         <tr>
                             <td>Data final</td>
                             <td><input type="text" name="data_final" value="<?= mdate('%d/%m/%Y', strtotime($row->data_final)); ?>" size="20" class="data" /></td>
                         </tr>
                         <tr>
                             <td colspan="2">
                                 <b>Detalhes</b><br/>
                                 <textarea name="detalhes" rows="9" cols="60" class="ckeditor"><?= $row->detalhes; ?></textarea>
                             </td>
                         </tr>
                         <tr>
                             <td>Foto</td>
                             <td><input type="file" name="userfile" size="35" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td></td>
                             <td><label><input type="checkbox" name="alterarFoto" value="1" /> Alterar foto</label></td>
                         </tr>
                         <tr>
                             <td>Local</td>
                             <td><input type="text" name="local" value="<?= $row->local; ?>" size="45" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Mapa</td>
                             <td><input type="text" name="mapa" value="<?= $row->mapa; ?>" size="45" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Site do evento</td>
                             <td><input type="text" name="site" value="<?= $row->site; ?>" size="45" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Telefone</td>
                             <td><input type="text" name="telefone" value="<?= $row->telefone; ?>" size="25" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Celular</td>
                             <td><input type="text" name="celular" value="<?= $row->celular; ?>" size="25" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Email</td>
                             <td><input type="text" name="email" value="<?= $row->email; ?>" size="45" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Valor normal</td>
                             <td><input type="text" name="valor_normal" value="<?= $row->valor_normal; ?>" size="15" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Valor antecipado</td>
                             <td><input type="text" name="valor_desconto" value="<?= $row->valor_desconto; ?>" size="15" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Validade do desconto</td>
                             <td><input type="text" name="data_desconto" value="<?= mdate('%d/%m/%Y', strtotime($row->data_desconto)); ?>" size="20" class="data" /></td>
                         </tr>
                         <tr>
                             <td>Status</td>
                             <td><input type="text" name="status" value="<?= $row->status; ?>" size="45" class="form_input" /></td>
                         </tr>
                         <tr>
                             <td>Cadastro</td>
                             <td><input type="text" name="data_cdastro" value="<?= mdate('%d/%m/%Y', strtotime($row->data_cdastro)); ?>" size="20" class="data" /></td>
                         </tr>
                         <tr>
                             <td></td>
                             <td>
                                 <input type="submit" value="Salvar" name="bot_salvar" class="ui-button botao" />
                                 <?= anchor('admin/eventos', 'Cancelar'); ?>
                             </td>
                         </tr>
                     </tbody>
                 </table>
             </form>
            <?php
        endswitch;
        ?>
    </div>
</div>
